<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../../../views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>解约审核列表</title>
<head>
    <meta charset="utf-8">
    <title>解约审核列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="/fdoctor-ms/statics/beginnerAdmin/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/fdoctor-ms/statics/beginnerAdmin/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/fdoctor-ms/statics/beginnerAdmin/css/btable.css" />
    
    <script type="text/javascript" src="/fdoctor-ms/statics/beginnerAdmin/plugins/layui/layui.js"></script>
    <script type="text/javascript" src="/fdoctor-ms/statics/js/jquery-2.1.4.min.js"></script>
    
</head>

<body style=" background-color: gainsboro;">
    <div style="margin:0px; background-color: white;">
        <blockquote class="layui-elem-quote">
        <form class="layui-form" action="" style="height:100px;">
    		<div class="layui-form-item" align="left" style="margin-left: 0px;margin-top: 10px;">
				<div class="layui-inline"  >
					<label class="layui-form-label">审核状态</label>
					<div class="layui-input-inline">
						<select name="status" lay-verify="" id="status">
						  <option value="0">全部</option>
						  <option value="1">待审核</option>
						  <option value="2">已拒绝</option>
						  <option value="3">已解约</option>
						</select> 
					</div>
				</div>
			</div>
				
				
			  <div class="layui-form-item" align="left" style="margin-left: 0px;margin-top: 10px;">  
			 <div class="layui-inline"  >
			    	<label class="layui-form-label">发起人</label>
			    	<div class="layui-input-inline">
			    		<select name="originator" lay-verify="" id="originator">
						  <option value="0">全部</option>
						  <option value="1">医生</option>
						  <option value="2">居民</option>
						</select>     
				    </div>
			  </div>
			  
			  <div class="layui-inline"  >
			    <label class="layui-form-label" style="width: 30px;" ></label>
			    	 <div class="layui-input-inline">
			    	<button class="layui-btn layui-btn-radius" style="width: 100%" id="selectButton" type="button">查询</button>
			    	</div>
			    </div>
			  </div>
			</form>
        </blockquote>
        <div id="content" style="width: 100%;height: 500px;"></div>
    </div>

    <script>
    
    	function tableConfig(){
    		layui.config({
                base: '/fdoctor-ms/statics/beginnerAdmin/js/'
            }).use(['btable','layer'], function () {
                var layer = layui.layer;
                
                var btable = layui.btable(),
                    $ = layui.jquery;
                
                btable.set({
                    elem: '#content',
                    url: '/fdoctor-ms/audit/queryRequestList',
                    pageSize: 10,
                    columns: [{
                        fieldName: '编号',
                        field: 'id',
                        hidden:	true
                    }, {
                        fieldName: '状态',
                        field: 'requestMap',
                        colRender: 'sRender'
                    }, {
                        fieldName: '时间',
                        field: 'requestDate'
                    }, {
                        fieldName: '发起人',
                        field: 'originator',
                        colRender: 'originatorRender'
                    }, {
                        fieldName: '签约人',
                        field: 'personName'
                    }, {
                        fieldName: '医生团队',
                        field: 'teamName'
                    }, {
                        fieldName: '区划',
                        field: 'region',
                        colRender: 'regionRender'
                    }, {
                        fieldName: '解约理由',
                        field: 'reasonAll'
                    }, {
                        fieldName: '操作',
                        field: 'requestMap',
                        colRender: 'crRender'
                    } ],
                    even: true,
                    //skin: 'row',
                    checkbox: false,
                    field: 'id',
                    paged: true,
                    params : getParams(),
                });
                btable.render();

                $(window).on('resize', function (e) {
                    var $that = $(this);
                    $('#content').height($that.height() - 92);
                }).resize();
                
                
            });
    	}
    	tableConfig();
    	
    	   
    
    	//查询按钮声明点击事件，查询逻辑
        $('#selectButton').on('click', function(){
        	tableConfig();
        });
    	
  
		function getParams(){
        	var params = {
        		originator : $('#originator').val(),
        		status: $('#status').val()
 			   	}
        	return params;
        }
        
        function originatorRender(data){
        	if(data='1'){
        		return '医生'
        	}else if(data=='2'){
        		return '居民'
        	}
        	else{
        		return data;
        	}
        }
        
        function sRender(data){
        	console.log(data)
        	//var map=eval(data);
        	var status= data.status
        	if(status == '1'){
        		return '<button data-method="offset" data-type="auto" style="background-color:gainsboro;color:red;font-weight:bold;" class="layui-btn layui-btn-normal"  >待审核</button>';
        	}else if(status == '2'){
        		return '<button data-method="offset" data-type="auto" style="background-color:gainsboro;color:gray;" class="layui-btn layui-btn-normal"  >已拒绝</button>';
        	}else if(status == '3'){
        		return '<button data-method="offset" data-type="auto" style="background-color:gainsboro;color:black;" class="layui-btn layui-btn-normal"  >已解约</button>';
        	}else{
        		return status;
        	}
        }
        
        
        function statusRender(data){
        	if(data=="null"||typeof (data)=="undefined"){
        		return '未知'
        	}else if(data==undefined||data==null){
        		return '未知'
        	}else if(data=='1'){
        		return '待审核'
        	}else if(data=='2'){
        		return '已拒绝'
        	}else if(data=='3'){
        		return '已解约'
        	}
        	else{
        		return '-';
        	}
        }
        
        function regionRender(data){
        	if(data==undefined || data==null){
        		return '暂无全名'
        	}
        	else{
        		return data;
        	}
        }
        
        function crRender(data){
        	console.log(data)
        	//var map=eval(data);
        	var status= data.status
        	var id=data.id
        	if(status == '1'){
        		return '<button data-method="offset" data-type="auto" style="width:100px;" class="layui-btn layui-btn-normal" onclick="goHand('+id+','+status+')" >去处理</button>';
        	}else if(status == '2'){
        		return '<button data-method="offset" data-type="auto" style="width:100px" class="layui-btn layui-btn-normal" onclick="goLook('+id+','+status+')" >查看</button>';
        	}else if(status == '3'){
        		return '<button data-method="offset" data-type="auto" style="width:100px" class="layui-btn layui-btn-normal" onclick="goLook('+id+','+status+')" >查看</button>';
        	}else{
        		return status;
        	}
        }
        
    </script>
   <script type="text/javascript">
   
   
   function  goHand(id,status){
	 var index = layer.open({
				    type: 2
		   		    ,scrollbar: true
		   		    ,fixed: true //不固定
				   	,area: 'auto'
				   	, maxmin: true 
				   	,skin: 'layui-layer-rim' //加上边框
		   	        ,title :'审核解约申请'
			   	    ,content: '/fdoctor-ms/audit/requestHandling?id='+id+'&status='+status
		   	        ,btnAlign: 'c' //按钮居中
		   	        ,shade: 0 //不显示遮罩
		   	       
		   	      });
	 layer.full(index);  
   }
   
   function  goLook(id,status){
		 var index = layer.open({
					    type: 2
			   		    ,scrollbar: true
			   		    ,fixed: true //不固定
					   	,area: 'auto'
					   	, maxmin: true 
					   	,skin: 'layui-layer-rim' //加上边框
			   	        ,title :'查看详情'
				   	    ,content: '/fdoctor-ms/audit/requestHandling?id='+id+'&status='+status
			   	        ,btnAlign: 'c' //按钮居中
			   	        ,shade: 0 //不显示遮罩
			   	       
			   	      });
		 layer.full(index);  
	   }
   </script>
</body>
</html>